from django.core.management.base import BaseCommand
import tsl_backend.users.models as users


class Command(BaseCommand):
    help = "Create new user"

    def add_arguments(self, parser):
        parser.add_argument("--username", type=str)
        parser.add_argument("--password", type=str)
        parser.add_argument("--staffcode", type=str)
        parser.add_argument("--cnName", type=str)

    
    def handle(self, *args, **options):
        username=options["username"]
        password=options["password"]
        staffcode=options["staffcode"]
        cnName=options["cnName"]
        if username and password:
            user_obj = users.User.objects.create_user(username=username, password=password, staffcode=staffcode, cnName=cnName)
            self.stdout.write(
                self.style.SUCCESS('Successfully to create roles for user')
            )
